﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;

namespace SimpleBlog.Tests.Mockup
{
    public class MockupHelper
    {
        public const int DefaultPageSize = 5;
        public const int FirstPageIndex = 0;

        public const int ModuleId = 321;
        public const int ValidModuleId = 1;
        public const int ValidUserId1 = 1;
        public const int ValidUserId2 = 1;

        public const int TestSet1_EntryId = 1;
        public const string TestSet1_Title = "Test Blog 1";
        public const string TestSet1_Summary = "Test Blog 1 Summary";
        public const string TestSet1_BlogContent = "Test Blog 1 Content";
        public const bool TestSet1_AllowComments = true;
        public const bool TestSet1_Published = true;
        public const int TestSet1_ModuleId = ModuleId;
        public const int TestSet1_CreatedByUserId = ValidUserId1;
        public static readonly DateTime TestSet1_CreatedOnDate = new DateTime(2010, 4, 24);
        public const int TestSet1_PublishedByUserId = ValidUserId1;
        public static readonly DateTime TestSet1_PublishedOnDate = new DateTime(2010, 4, 24);
        public const int TestSet1_LastModifiedByUserId = ValidUserId1;
        public static readonly DateTime TestSet1_LastModifiedOnDate = new DateTime(2010, 4, 24);

        public static DataTable CreateDataTableForEntry()
        {
            DataTable dt = new DataTable();
            dt.Columns.Add("EntryId", typeof(int));
            dt.Columns.Add("Title", typeof(string));
            dt.Columns.Add("Summary", typeof(string));
            dt.Columns.Add("BlogContent", typeof(string));
            dt.Columns.Add("AllowComments", typeof(bool));
            dt.Columns.Add("Published", typeof(bool));
            dt.Columns.Add("ModuleId", typeof(int));
            dt.Columns.Add("CreatedByUserId", typeof(int));
            dt.Columns.Add("CreatedOnDate", typeof(DateTime));
            dt.Columns.Add("PublishedByUserId", typeof(int));
            dt.Columns.Add("PublishedOnDate", typeof(DateTime));
            dt.Columns.Add("LastModifiedByUserId", typeof(int));
            dt.Columns.Add("LastModifiedOnDate", typeof(DateTime));
            return dt;
        }

        public static void AddTestSet1(DataTable dt)
        {
            DataRow dr = dt.NewRow();
            dr["EntryId"] = TestSet1_EntryId;
            dr["Title"] = TestSet1_Title;
            dr["Summary"] = TestSet1_Summary;
            dr["BlogContent"] = TestSet1_BlogContent;
            dr["AllowComments"] = TestSet1_AllowComments;
            dr["Published"] = TestSet1_Published;
            dr["ModuleId"] = TestSet1_ModuleId;
            dr["CreatedByUserId"] = TestSet1_CreatedByUserId;
            dr["CreatedOnDate"] = TestSet1_CreatedOnDate;
            dr["PublishedByUserId"] = TestSet1_PublishedByUserId;
            dr["PublishedOnDate"] = TestSet1_PublishedOnDate;
            dr["LastModifiedByUserId"] = TestSet1_LastModifiedByUserId;
            dr["LastModifiedOnDate"] = TestSet1_LastModifiedOnDate;
            dt.Rows.Add(dr);
        }

        public static IDataReader GetPublishedEntriesPagedTestDataReader()
        {
            DataTable dt = CreateDataTableForEntry();
            AddTestSet1(dt);
            return dt.CreateDataReader();
        }

    }
}
